# define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int get_days(int x, int y)
{
    int day = 0;
    switch (y)
    {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
        day = 31;
        break;
    case 4:
    case 6:
    case 9:
    case 11:
        day = 30;
        break;
    case 2:
    {

        day = 28;
        if ((x % 4 == 0) && (x % 100 != 0) || (x % 400 == 0))
        {
            day++;
        }
        break;
    }

    }
    return day;
}

int main()
{
    int x = 0;
    int y = 0;
  

    while (scanf("%d %d", &x, &y) == 2)
    {
        int ret = get_days(x, y);
        printf("%d\n", ret);
    }

    return 0;
}